package com.yj.suncity.activity.shouye;

import org.json.JSONObject;

import com.yj.suncity.R;
import com.yj.suncity.async.AsyncTaskUtil;
import com.yj.suncity.async.AsyncTaskUtil.ResultCallBack;
import com.yj.suncity.constant.URLCon;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.TextView;

public class MyYinkuNumActivity extends Activity {
	private Context context;
	private String userId;
	private boolean isShop;
	private TextView /*mTxt_jinbi_num*/ mTxt_yinyuan_num, /*mTxt_zhuanJinbi_num*/
			mTxt_zhuanYinyuan_num, mTxt_duihuanYinyuan_num,
			mTxt_tixianYinyuan_num;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_my_yinku_num);
		context = this;
		userId = getIntent().getStringExtra("userid");
		isShop = getIntent().getBooleanExtra("isshop", false);
		findView();
		initData();
	}

	private void findView() {
//		mTxt_jinbi_num = (TextView) findViewById(R.id.txt_jinbi_num);
		mTxt_yinyuan_num = (TextView) findViewById(R.id.txt_yinyuan_num);

//		mTxt_zhuanJinbi_num = (TextView) findViewById(R.id.txt_zhuanjinbi_num);
		mTxt_zhuanYinyuan_num = (TextView) findViewById(R.id.txt_zhuanyinyuan_num);
		mTxt_duihuanYinyuan_num = (TextView) findViewById(R.id.txt_duihuanyinyuan_num);
		mTxt_tixianYinyuan_num = (TextView) findViewById(R.id.txt_tixianyinyuan_num);

	}

	private void initData() {
		String path = URLCon.用户 + "?action=treasury&memberid=" + userId;
		Log.d("", path);
		AsyncTaskUtil asyncTaskUtil = new AsyncTaskUtil(context, null, null,
				false, null, true, "正在加载......", new ResultCallBack() {
					@Override
					public void JSONResult(JSONObject jsonObject) {
//						mTxt_jinbi_num.setText(jsonObject.optString("jb"));
						double mCash = Double.parseDouble(jsonObject.optString("jb"));
						long cash = Math.round(mCash * 10);
						mCash = cash / 100.0;
						mTxt_yinyuan_num.setText((mCash+Double.parseDouble(jsonObject.optString("zyys")))+"元");
						
						mCash = Double.parseDouble(jsonObject.optString("zqjb"));
						cash = Math.round(mCash * 10);
						mCash = cash / 100.0;
//						mTxt_zhuanJinbi_num.setText(jsonObject.optString("zqjb"));
						mTxt_zhuanYinyuan_num.setText((mCash+Double.parseDouble(jsonObject.optString("zqyys")))+"元");
						mTxt_duihuanYinyuan_num.setText(jsonObject.optString("gmyys")+"元");
						mTxt_tixianYinyuan_num.setText(jsonObject.optString("txyy")+"元");
					}
				});
		asyncTaskUtil.execute(path);
	}

	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.btnHeadBack:
			this.finish();
			break;

		default:
			break;
		}

	}

}
